home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / FrexxEd / fpl / WordWrap.FPL < prev    next >
Encoding:
Text File  |  1996-09-27  |  1.4 KB  |  52 lines

  1. export int WordWrap_hook(void)
  2. {
  3.   if(ReadInfo("wall_right") >= ReadInfo("line_length"))
  4.     return;
  5.   {
  6.     int line=ReadInfo("line");
  7.     int steps;
  8.     int sbyte=ReadInfo("byte_position");
  9.     int jumpback;
  10.     if(ReadInfo("wall_right") >= ReadInfo("column"))
  11.       jumpback=1;
  12.     GotoLine(line, ReadInfo("line_length")); /* jump to end of line! */
  13.     do {
  14.       steps+=CursorLeftWord();
  15.     } while (line==ReadInfo("line") && ReadInfo("column")>1 &&
  16.              (ReadInfo("wall_right") < ReadInfo("column")));
  17.  
  18.     if (line==ReadInfo("line") && ReadInfo("column")>1) {
  19.       int byte = ReadInfo("byte_position");
  20.       while(GetChar(--byte) != ' ')
  21.       {
  22.          steps++;
  23.          CursorLeft();
  24.          if(!byte)
  25.          {
  26.             GotoLine(line,ReadInfo("wall_right"));
  27.             Output("\n");
  28.             return;
  29.          }
  30.       }
  31.       byte++;
  32.       while(GetChar(--byte) == ' ')
  33.         Backspace();
  34.       Output("\n");
  35.     }
  36.     CursorRight(steps);
  37.     if(ReadInfo("wall_right") <= ReadInfo("column"))
  38.       Output("\n");
  39.     if(jumpback)
  40.       GotoLine(line, sbyte); /* jump to start-pos! */
  41.   }
  42. }
  43.  
  44. ConstructInfo("wall_right", "", "", "WIL", "", 0, 999, 79);
  45. ConstructInfo("wordwrap", "", "", "WBL", "", 0, 0);
  46.  
  47. AddMode(0,"wordwrap", "","");                // Add as minor mode!
  48.  
  49. HookPast("Output", "WordWrap_hook();", "wordwrap");
  50. HookPast("BlockPaste", "WordWrap_hook();", "wordwrap");
  51.  
  52.